/*
 * Shared visual layer for Bootstrap-based pages.
 * Keep layout ownership in each page stylesheet; this file only normalizes
 * typography, color, controls, feedback, and low-cost interaction states.
 */
:root {
    --ui-page: #f5f5f7;
    --ui-surface: #ffffff;
    --ui-surface-soft: #f2f2f4;
    --ui-surface-raised: #fbfbfd;
    --ui-text: #1d1d1f;
    --ui-muted: #686870;
    --ui-border: #d9d9de;
    --ui-border-strong: #c5c5cc;
    --ui-primary: #006fc4;
    --ui-primary-hover: #005fa9;
    --ui-primary-soft: #eaf4ff;
    --ui-success: #24774f;
    --ui-danger: #c4323d;
    --ui-warning: #946200;
    --ui-info: #19768d;
    --ui-nav: rgba(251, 251, 253, 0.84);
    --ui-focus: rgba(6, 118, 206, 0.22);
    --ui-shadow-sm: 0 1px 2px rgba(37, 42, 50, 0.06), 0 8px 24px rgba(37, 42, 50, 0.035);
    --ui-shadow-md: 0 18px 44px rgba(37, 42, 50, 0.12);
    --ui-radius: 8px;
    --ui-transition: 160ms ease;
    --ui-workspace-wide: 1920px;
    --ui-workspace-standard: 1760px;
    --ui-workspace-reading: 1040px;
    --ui-page-gutter: clamp(12px, 1.2vw, 24px);
    --ui-translation-gutter: clamp(28px, 2.5vw, 38px);
}

*,
*::before,
*::after {
    letter-spacing: 0;
}

html {
    color-scheme: light;
    background: var(--ui-page);
    -webkit-text-size-adjust: 100%;
}

body {
    min-width: 320px;
    color: var(--ui-text);
    background-color: var(--ui-page);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
    font-size: 0.9375rem;
    line-height: 1.55;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

/* Shared workspace geometry. Page styles still own their internal layouts. */
body.workspace-page {
    max-width: 100%;
    overflow-x: clip;
}

body.workspace-page > .content-wrapper {
    width: 100%;
    max-width: var(--ui-workspace-wide);
    min-width: 0;
    margin-inline: auto;
}

body.workspace-page > .content-wrapper > .tool-container,
body.workspace-page > .content-wrapper > .tool-container > .tool-section,
body.workspace-page > .content-wrapper > .tool-container > .tool-section > .tool-card {
    min-width: 0;
}

body.text-translator-page > .content-wrapper {
    max-width: var(--ui-workspace-wide);
}

body.realtime-transcription-page > .content-wrapper {
    max-width: var(--ui-workspace-wide);
}

body.video-downloader-page > .content-wrapper {
    max-width: var(--ui-workspace-standard);
    padding: 24px var(--ui-page-gutter) 64px;
}

body.video-downloader-page .tool-container {
    width: 100%;
    margin: 0 auto;
}

body.video-downloader-page .tool-card {
    overflow: hidden;
    border: 1px solid var(--ui-border);
}

body.video-downloader-page .tool-card-body {
    padding: clamp(18px, 2.5vw, 28px);
}

body.video-processor-page > .content-wrapper {
    max-width: var(--ui-workspace-wide);
    padding: 20px var(--ui-page-gutter) 64px;
}

body.video-processor-page .tool-container {
    overflow: visible;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

body.video-processor-page .tool-section {
    margin-bottom: 0;
}

body.video-processor-page .tool-card,
body.video-processor-page .tool-card:hover,
body.video-processor-page .tool-card:focus-visible {
    overflow: hidden;
    margin: 0;
    border: 1px solid var(--ui-border) !important;
    border-radius: var(--ui-radius);
    background: var(--ui-surface);
    box-shadow: var(--ui-shadow-sm);
    transform: none;
}

body.image-translator-page .tool-container {
    max-width: none;
}

/* Translation tools use the viewport as working space instead of a fixed canvas. */
body.translation-workspace > .content-wrapper {
    width: 100%;
    max-width: none;
    padding-right: var(--ui-translation-gutter);
    padding-left: var(--ui-translation-gutter);
}

body.translation-workspace > .content-wrapper > .tool-container {
    width: 100%;
    max-width: none;
    margin-right: 0;
    margin-left: 0;
}

body.translation-workspace .navbar > .container-fluid {
    width: 100%;
    max-width: none;
    padding-right: var(--ui-translation-gutter);
    padding-left: var(--ui-translation-gutter);
}

.profile-body .profile-container {
    width: calc(100% - var(--ui-page-gutter) - var(--ui-page-gutter));
    max-width: var(--ui-workspace-standard);
    margin: clamp(18px, 2.4vw, 32px) auto 64px;
}

.admin-container {
    width: 100%;
    max-width: var(--ui-workspace-wide) !important;
    padding-inline: var(--ui-page-gutter) !important;
}

.tts-page .tts-shell {
    width: 100%;
    max-width: var(--ui-workspace-wide);
    padding-inline: var(--ui-page-gutter);
}

::selection {
    color: #14202a;
    background: #cfe3f4;
}

a {
    color: var(--ui-primary);
    text-underline-offset: 0.16em;
    transition: color var(--ui-transition);
}

a:hover {
    color: var(--ui-primary-hover);
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--ui-text);
    font-weight: 650;
    line-height: 1.3;
}

p,
.form-text,
.text-muted {
    line-height: 1.6;
}

.text-muted,
.form-text {
    color: var(--ui-muted) !important;
}

/* Fixed light navigation across the Bootstrap pages. */
.navbar.bg-dark,
.navbar-dark.bg-dark {
    border-bottom: 1px solid var(--ui-border);
    background-color: var(--ui-nav) !important;
    -webkit-backdrop-filter: blur(22px) saturate(160%);
    backdrop-filter: blur(22px) saturate(160%);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.72);
}

.navbar {
    min-height: 56px;
}

.navbar > .container-fluid {
    width: 100%;
    max-width: var(--ui-workspace-wide);
    margin-inline: auto;
    padding-inline: var(--ui-page-gutter);
}

.navbar .navbar-brand {
    color: var(--ui-text) !important;
    font-weight: 650;
}

.navbar .nav-link,
.navbar .nav-link.text-light,
.navbar span.nav-link {
    border-radius: 6px;
    color: var(--ui-muted) !important;
    transition: color var(--ui-transition), background-color var(--ui-transition);
}

.navbar .nav-link:hover,
.navbar .nav-link:focus-visible {
    color: var(--ui-text) !important;
    background-color: var(--ui-surface-soft);
}

.navbar .nav-link::after,
.navbar .nav-link::before {
    background-color: var(--ui-primary) !important;
    transition-duration: var(--ui-transition);
}

.navbar .btn-link.text-light {
    color: var(--ui-text) !important;
    background: transparent;
}

.navbar .btn-link.text-light:hover,
.navbar .btn-link.text-light:focus-visible {
    color: var(--ui-primary) !important;
    background: var(--ui-surface-soft);
}

.navbar .btn-dark,
.navbar #mobileMenuButton {
    color: var(--ui-text) !important;
    border-color: transparent !important;
    background: transparent !important;
}

.navbar .btn-dark:hover,
.navbar .btn-dark:focus-visible,
.navbar #mobileMenuButton:hover,
.navbar #mobileMenuButton:focus-visible,
.navbar #mobileMenuButton[aria-expanded="true"] {
    color: var(--ui-text) !important;
    border-color: var(--ui-border) !important;
    background: var(--ui-surface-soft) !important;
}

.navbar .btn-outline-light {
    color: var(--ui-muted) !important;
    border-color: var(--ui-border-strong) !important;
    background: transparent !important;
}

.navbar .btn-outline-light:hover,
.navbar .btn-outline-light:focus-visible {
    color: var(--ui-text) !important;
    border-color: var(--ui-border-strong) !important;
    background: var(--ui-surface-soft) !important;
    box-shadow: none;
}

.dropdown-menu,
.dropdown-menu-dark {
    padding: 0.4rem;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    color: var(--ui-text);
    background-color: var(--ui-surface) !important;
    box-shadow: var(--ui-shadow-md);
}

.dropdown-menu-dark {
    border-color: var(--ui-border);
}

.dropdown-item {
    min-height: 36px;
    padding: 0.48rem 0.7rem;
    border-radius: 5px;
    line-height: 1.35;
}

.dropdown-menu-dark .dropdown-item,
.dropdown-menu .dropdown-item {
    color: var(--ui-text) !important;
    background: transparent;
}

.dropdown-menu-dark .dropdown-item:hover,
.dropdown-menu-dark .dropdown-item:focus,
.dropdown-menu .dropdown-item:hover,
.dropdown-menu .dropdown-item:focus {
    color: var(--ui-text) !important;
    background-color: var(--ui-primary-soft) !important;
}

.dropdown-menu-dark .dropdown-divider,
.dropdown-menu .dropdown-divider {
    border-color: var(--ui-border);
    opacity: 1;
}

/* Buttons use stable dimensions and restrained compositor-only motion. */
.btn {
    min-height: 38px;
    border-radius: 9px;
    font-weight: 600;
    line-height: 1.35;
    box-shadow: none;
    transition: color var(--ui-transition), background-color var(--ui-transition), border-color var(--ui-transition), box-shadow var(--ui-transition), transform var(--ui-transition);
}

.btn-sm {
    min-height: 32px;
    font-size: 0.8125rem;
}

.btn-lg {
    min-height: 44px;
}

.btn:not(.btn-link):not(:disabled):hover {
    transform: translateY(-1px);
}

.btn:not(.btn-link):not(:disabled):active {
    transform: translateY(0);
}

.btn-primary {
    border-color: var(--ui-primary) !important;
    background-color: var(--ui-primary) !important;
}

.btn-dark {
    color: #f8fbff;
    border-color: var(--ui-primary) !important;
    background-color: var(--ui-primary) !important;
}

.btn-dark:hover,
.btn-dark:focus-visible {
    color: #f8fbff;
    border-color: var(--ui-primary-hover) !important;
    background-color: var(--ui-primary-hover) !important;
}

.btn-primary:hover,
.btn-primary:focus-visible {
    border-color: var(--ui-primary-hover) !important;
    background-color: var(--ui-primary-hover) !important;
    box-shadow: 0 4px 12px rgba(37, 99, 166, 0.2);
}

.btn-outline-primary {
    color: var(--ui-primary);
    border-color: #7ea1c4;
}

.btn-outline-primary:hover {
    color: #ffffff;
    border-color: var(--ui-primary);
    background-color: var(--ui-primary);
}

.btn-success {
    border-color: var(--ui-success) !important;
    background-color: var(--ui-success) !important;
}

.btn-danger {
    border-color: var(--ui-danger) !important;
    background-color: var(--ui-danger) !important;
}

.btn-info {
    color: #ffffff;
    border-color: var(--ui-info) !important;
    background-color: var(--ui-info) !important;
}

.btn-warning {
    color: #ffffff;
    border-color: var(--ui-warning) !important;
    background-color: var(--ui-warning) !important;
}

.btn-outline-secondary {
    color: #53616d;
    border-color: var(--ui-border-strong);
}

.btn-outline-secondary:hover {
    color: #27323b;
    border-color: #a9b5bf;
    background-color: #edf1f4;
}

.btn-outline-light {
    color: var(--ui-muted);
    border-color: var(--ui-border-strong);
}

.btn:disabled,
.btn.disabled {
    transform: none !important;
    box-shadow: none !important;
    cursor: not-allowed;
    opacity: 0.58;
}

.btn-link.text-light:hover {
    transform: translateX(-1px);
}

/* Form controls share a readable type size and consistent focus feedback. */
.form-label,
label:not(.form-check-label) {
    margin-bottom: 0.4rem;
    color: #34414c;
    font-size: 0.875rem;
    font-weight: 600;
}

.form-control,
.form-select,
.lang-select,
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="search"],
input[type="url"],
textarea,
select {
    color: var(--ui-text);
    border-color: var(--ui-border-strong);
    border-radius: 10px;
    background-color: var(--ui-surface);
    transition: border-color var(--ui-transition), box-shadow var(--ui-transition), background-color var(--ui-transition);
}

.form-control:not(.form-control-sm),
.form-select:not(.form-select-sm) {
    min-height: 40px;
    font-size: 0.9375rem;
    line-height: 1.45;
}

textarea.form-control,
textarea {
    line-height: 1.6;
}

.form-control::placeholder,
textarea::placeholder,
input::placeholder {
    color: #8a959f;
    opacity: 1;
}

.form-control:hover,
.form-select:hover,
input:hover,
textarea:hover,
select:hover {
    border-color: #9eabb6;
}

.form-control:focus,
.form-select:focus,
input:focus,
textarea:focus,
select:focus {
    color: var(--ui-text);
    border-color: #5d8fbd;
    outline: 0;
    box-shadow: 0 0 0 0.2rem var(--ui-focus);
}

.form-check-input:checked {
    border-color: var(--ui-primary);
    background-color: var(--ui-primary);
}

.form-check-input:focus {
    border-color: #5d8fbd;
    box-shadow: 0 0 0 0.2rem var(--ui-focus);
}

.input-group > .btn {
    min-width: 40px;
}

.input-group-text {
    color: var(--ui-muted);
    border-color: var(--ui-border-strong);
    background-color: var(--ui-surface-soft);
}

/* Surfaces stay crisp and utilitarian with one shared elevation scale. */
.card,
.tool-card,
.profile-card,
.token-card,
.user-card,
.tab-content,
.token-usage-detail,
.modal-content {
    border-color: var(--ui-border);
    border-radius: var(--ui-radius);
    background-color: var(--ui-surface);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.88), var(--ui-shadow-sm);
}

.token-card.total-tokens,
.total-tokens {
    border-color: #c8dceb;
    background: var(--ui-surface) !important;
}

.profile-container {
    box-shadow: none !important;
}

.profile-tabs {
    border-color: var(--ui-border);
    background-color: var(--ui-surface-soft);
}

.profile-tabs .nav-link.active {
    color: var(--ui-primary);
    border-color: var(--ui-primary);
    background-color: var(--ui-surface);
}

.list-group > .tool-card {
    border-radius: var(--ui-radius);
}

.card-header,
.modal-header,
.tool-card-header,
.panel-header,
.mobile-panel-header {
    color: var(--ui-text);
    border-color: var(--ui-border);
    background-color: var(--ui-surface-soft);
}

.card-header {
    font-weight: 650;
}

.card-footer,
.modal-footer {
    border-color: var(--ui-border);
    background-color: var(--ui-surface-soft);
}

.tool-card-body,
.content-area,
.mobile-content-area,
.translation-output,
.text-panel,
.transcription-panel,
.translation-panel,
.mobile-panel,
.result-container {
    color: var(--ui-text);
    border-color: var(--ui-border);
    background-color: var(--ui-surface);
}

.modal-content {
    overflow: hidden;
    border-radius: var(--ui-radius) !important;
    box-shadow: 0 18px 48px rgba(24, 36, 48, 0.18);
}

.modal-title {
    font-size: 1.05rem;
    font-weight: 650;
}

.tool-card {
    border-color: var(--ui-border) !important;
    color: var(--ui-text);
    transition: border-color var(--ui-transition), box-shadow var(--ui-transition), transform var(--ui-transition);
}

.tool-card:hover,
.tool-card:focus-visible {
    z-index: 1;
    color: var(--ui-text);
    border-color: #a9bac8 !important;
    box-shadow: 0 8px 22px rgba(24, 36, 48, 0.1);
    transform: translateY(-2px);
}

.tool-card .tool-title {
    color: var(--ui-text);
    font-size: 1rem;
    line-height: 1.35;
}

.tool-card .tool-description {
    color: var(--ui-muted);
    line-height: 1.55;
}

.tool-icon {
    flex: 0 0 auto;
    border-radius: 7px !important;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}

.list-group-item {
    color: var(--ui-text);
    border-color: var(--ui-border);
    background-color: var(--ui-surface);
}

.list-group-item-action {
    transition: color var(--ui-transition), background-color var(--ui-transition), border-color var(--ui-transition);
}

.list-group-item-action:hover,
.list-group-item-action:focus {
    background-color: #f7f9fb;
}

.nav-tabs {
    border-color: var(--ui-border);
}

.nav-tabs .nav-link {
    color: var(--ui-muted);
    font-weight: 600;
}

.nav-tabs .nav-link:hover {
    color: var(--ui-primary);
    border-color: transparent;
}

.nav-tabs .nav-link.active {
    color: var(--ui-primary);
    border-color: var(--ui-border) var(--ui-border) var(--ui-surface);
}

.table {
    color: var(--ui-text);
    border-color: var(--ui-border);
    vertical-align: middle;
}

.table > :not(caption) > * > * {
    padding: 0.7rem 0.75rem;
}

.table thead th {
    color: #4b5965;
    background-color: var(--ui-surface-soft);
    font-size: 0.8125rem;
    font-weight: 650;
}

.table-light,
.table-light > th,
.table-light > td {
    color: var(--ui-text);
    background-color: var(--ui-surface-soft);
}

.badge {
    border-radius: 5px;
    font-weight: 650;
}

.alert {
    border-width: 1px;
    border-radius: var(--ui-radius);
    line-height: 1.5;
}

.alert-info {
    color: #23576a;
    border-color: #bddce4;
    background-color: #edf8fa;
}

.alert-success {
    color: #225f46;
    border-color: #b9dccb;
    background-color: #edf8f2;
}

.alert-danger {
    color: #84323b;
    border-color: #e8c0c5;
    background-color: #fcedef;
}

.toast,
.toast.bg-danger,
.toast.bg-success,
.toast.bg-info,
.toast.bg-warning {
    color: var(--ui-text) !important;
    border: 1px solid var(--ui-border) !important;
    border-left-width: 3px !important;
    background-color: rgba(255, 255, 255, 0.97) !important;
    box-shadow: var(--ui-shadow-md) !important;
}

.toast.bg-danger,
.toast.error {
    border-left-color: var(--ui-danger) !important;
}

.toast.bg-success,
.toast.success {
    border-left-color: var(--ui-success) !important;
}

.toast.bg-info,
.toast.info {
    border-left-color: var(--ui-info) !important;
}

.toast.bg-warning,
.toast.warning {
    border-left-color: var(--ui-warning) !important;
}

.toast .btn-close-white,
.toast .btn-close {
    filter: none !important;
}

.progress {
    border-radius: 5px;
    background-color: #e7ecef;
}

.progress-bar {
    background-color: var(--ui-primary);
}

/* Shared context entry: gray when empty, amber when background or terms exist. */
#contextPromptBtn {
    display: inline-flex !important;
    width: 24px !important;
    height: 24px !important;
    min-width: 24px !important;
    min-height: 24px !important;
    flex: 0 0 24px !important;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    border: 1px solid #c9d1d8 !important;
    border-radius: 50% !important;
    color: #68747e !important;
    background: #ffffff !important;
    box-shadow: var(--ui-shadow-sm);
}

#contextPromptBtn i {
    margin: 0 !important;
    font-size: 0.7rem !important;
    line-height: 1;
}

#contextPromptBtn .context-prompt-symbol {
    display: block;
    margin: 0;
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1;
}

#contextPromptBtn:hover,
#contextPromptBtn:focus-visible {
    color: #76500f !important;
    border-color: #d2a64d !important;
    background: #fff9e9 !important;
}

#contextPromptBtn.context-enabled,
#contextPromptBtn.has-prompt {
    color: #8b5d0d !important;
    border-color: #dfa92f !important;
    background: #fff5d6 !important;
    box-shadow: 0 0 0 3px rgba(223, 169, 47, 0.12);
}

.context-glossary-dialog {
    max-width: 720px;
}

.context-glossary-dialog .modal-content {
    max-height: min(760px, calc(100vh - 32px));
}

.context-glossary-dialog .modal-header {
    align-items: flex-start;
}

.context-enabled-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    padding: 11px 12px;
    border: 1px solid #d4d9de;
    border-radius: 6px;
    background: #f7f8f9;
}

.context-enabled-row label,
.context-enabled-row small {
    display: block;
}

.context-enabled-row label {
    color: #46515b;
    font-weight: 600;
}

.context-enabled-row small {
    margin-top: 2px;
    color: #6b757e;
}

.context-enabled-row.is-enabled {
    border-color: #b7d9c3;
    background: #edf8f1;
}

.context-enabled-row.is-enabled label {
    color: #245c3a;
}

.context-enabled-row.is-enabled small {
    color: #4f725d;
}

#contextPromptBtn.context-disabled,
.context-prompt-btn.context-disabled {
    border-color: #cbd1d6 !important;
    color: #747d84 !important;
    background: #eef0f2 !important;
}

.context-modal-subtitle {
    margin: 0.18rem 0 0;
    color: var(--ui-muted);
    font-size: 0.78rem;
    line-height: 1.4;
}

.context-modal-body {
    overflow-y: auto;
}

.context-modal-body #contextPromptInput {
    min-height: 126px;
    resize: vertical;
}

.context-term-heading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 1rem 0 0.5rem;
    color: var(--ui-text);
    font-size: 0.875rem;
}

.context-term-heading span {
    color: var(--ui-muted);
    font-size: 0.75rem;
}

.context-term-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 18px minmax(0, 1fr) 36px;
    align-items: center;
    gap: 0.45rem;
}

.context-term-language-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 18px minmax(0, 1fr) 36px;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.45rem;
}

.context-term-language-form > i {
    display: grid;
    width: 18px;
    height: 32px;
    place-items: center;
    justify-self: center;
    color: #98a3ad;
}

.context-term-language-form::after {
    width: 36px;
    content: "";
}

.context-term-form > i {
    display: grid;
    width: 18px;
    height: 32px;
    margin: 0 !important;
    place-items: center;
    justify-self: center;
    color: #98a3ad;
}

.context-term-form .form-control,
.context-term-form .form-select {
    min-width: 0;
}

.context-term-add {
    width: 36px;
    min-width: 36px;
    padding: 0;
}

.context-term-corrections {
    margin-top: 0.45rem;
}

.context-prompt-feedback {
    margin: 0.6rem 0 0;
    padding: 0.55rem 0.65rem;
    border: 1px solid #cfd8df;
    border-radius: 6px;
    color: #40515e;
    background: #f5f8fa;
    font-size: 0.8125rem;
}

.context-prompt-feedback[data-status="success"] {
    border-color: #a8cfb7;
    color: #28643f;
    background: #edf8f1;
}

.context-prompt-feedback[data-status="error"] {
    border-color: #e4b7bc;
    color: #8d3037;
    background: #fcedef;
}

.context-prompt-feedback[data-status="warning"] {
    border-color: #dfc58d;
    color: #73551e;
    background: #fff8e8;
}

.context-glossary-list {
    min-height: 48px;
    max-height: 260px;
    margin-top: 0.6rem;
    overflow-y: auto;
    border: 1px solid var(--ui-border);
    border-radius: 6px;
    background: var(--ui-surface-soft);
}

.context-glossary-empty,
.context-glossary-loading {
    padding: 0.9rem;
    color: var(--ui-muted);
    font-size: 0.8125rem;
    text-align: center;
}

.context-glossary-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 18px minmax(0, 1fr) 30px;
    min-height: 42px;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.55rem;
    border-bottom: 1px solid var(--ui-border);
    font-size: 0.8125rem;
}

.context-glossary-item:last-child {
    border-bottom: 0;
}

.context-glossary-item > span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.context-glossary-arrow {
    display: grid;
    width: 18px;
    height: 28px;
    place-items: center;
    color: #96a1aa;
}

.context-glossary-item > span:nth-of-type(2) {
    padding-inline: 4px;
    direction: auto;
    unicode-bidi: plaintext;
}

.context-term-delete {
    display: inline-grid;
    width: 28px;
    height: 28px;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 5px;
    color: var(--ui-danger);
    background: transparent;
}

.context-term-delete:hover,
.context-term-delete:focus-visible {
    background: #fcedef;
}

.profile-settings-heading {
    margin-bottom: 1.25rem;
}

.profile-settings-heading h3 {
    margin: 0;
    color: var(--ui-text);
    font-size: 1.1rem;
    font-weight: 650;
}

.profile-settings-heading p {
    margin: 0.3rem 0 0;
    color: var(--ui-muted);
    font-size: 0.82rem;
}

.profile-settings-content {
    width: 100%;
}

.profile-font-settings {
    margin-bottom: 1.25rem;
    padding: clamp(14px, 1.5vw, 20px);
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    background: var(--ui-surface-raised);
}

.profile-setting-section-heading {
    margin-bottom: 1rem;
}

.profile-setting-section-heading .form-text {
    margin-top: 0.2rem;
}

.profile-font-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.profile-font-control {
    min-width: 0;
    padding: 0.9rem 1rem;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    background: var(--ui-surface);
}

.profile-font-control-label,
.profile-font-scale {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.profile-font-control-label {
    margin-bottom: 0.7rem;
}

.profile-font-control-label label {
    margin: 0;
    color: var(--ui-text);
    font-weight: 600;
}

.profile-font-value {
    min-width: 52px;
    padding: 0.18rem 0.45rem;
    border: 1px solid #bfd1df;
    border-radius: 6px;
    color: #064d82;
    background: var(--ui-primary-soft);
    font-variant-numeric: tabular-nums;
    font-weight: 650;
    text-align: center;
}

.profile-timing-value {
    min-width: 64px;
}

.profile-font-range.form-range {
    --range-thumb-size: 18px;
    --range-progress: 33.333%;
    width: 100%;
    height: 24px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    cursor: pointer;
}

.profile-font-range.form-range:focus {
    box-shadow: none;
}

.profile-font-range.form-range::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    border: 0;
    border-radius: 3px;
    background: linear-gradient(
        to right,
        var(--ui-primary) 0,
        var(--ui-primary) var(--range-progress),
        #dce1e6 var(--range-progress),
        #dce1e6 100%
    );
}

.profile-font-range.form-range::-webkit-slider-thumb {
    width: var(--range-thumb-size);
    height: var(--range-thumb-size);
    margin-top: calc((6px - var(--range-thumb-size)) / 2);
    border: 2px solid var(--ui-surface);
    border-radius: 50%;
    background: var(--ui-primary);
    box-shadow: 0 0 0 1px #7aa6c6, 0 2px 5px rgba(31, 53, 70, 0.22);
}

.profile-font-range.form-range:focus-visible::-webkit-slider-thumb {
    box-shadow: 0 0 0 4px var(--ui-focus), 0 0 0 1px #5d8fbd;
}

.profile-font-range.form-range::-moz-range-track {
    height: 6px;
    border: 0;
    border-radius: 3px;
    background: #dce1e6;
}

.profile-font-range.form-range::-moz-range-progress {
    height: 6px;
    border-radius: 3px;
    background: var(--ui-primary);
}

.profile-font-range.form-range::-moz-range-thumb {
    width: var(--range-thumb-size);
    height: var(--range-thumb-size);
    border: 2px solid var(--ui-surface);
    border-radius: 50%;
    background: var(--ui-primary);
    box-shadow: 0 0 0 1px #7aa6c6, 0 2px 5px rgba(31, 53, 70, 0.22);
}

.profile-font-scale {
    margin-top: 0.15rem;
    color: var(--ui-muted);
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
}

body.video-processor-page .video-text-results {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 20px;
}

body.video-processor-page .video-text-results .text-section {
    width: 100%;
    min-width: 0;
    margin: 0;
}

.profile-settings-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--ui-border);
}

.error-message {
    color: var(--ui-danger) !important;
    font-size: 0.875rem;
    line-height: 1.5;
}

.message-bubble,
.friend-item,
.group-item,
.result-container,
.content-area {
    border-color: var(--ui-border);
}

.chat-layout {
    background-color: var(--ui-page);
}

.friends-sidebar,
.chat-area,
.chat-header,
.chat-input,
.friends-header,
.group-list,
.rooms-list,
.main-content {
    color: var(--ui-text);
    border-color: var(--ui-border);
    background-color: var(--ui-surface);
}

.chat-messages,
.friend-request-entry,
.add-friend,
.group-members-list {
    color: var(--ui-text);
    border-color: var(--ui-border);
    background-color: var(--ui-surface-soft);
}

.message-sent {
    background-color: var(--ui-primary);
}

.message-received {
    color: var(--ui-text);
    background-color: #edf1f4;
}

footer {
    right: 0;
    left: 0;
    color: var(--ui-muted);
    border-color: var(--ui-border) !important;
    background-color: rgba(251, 251, 253, 0.9) !important;
    -webkit-backdrop-filter: blur(22px) saturate(150%);
    backdrop-filter: blur(22px) saturate(150%);
}

footer a {
    color: var(--ui-muted) !important;
}

.site-compliance-footer {
    width: 100%;
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 7px max(12px, env(safe-area-inset-right)) calc(7px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    border-top: 1px solid var(--ui-border);
    background: rgba(251, 251, 253, 0.92) !important;
    font-size: 0.75rem;
    line-height: 1.4;
}

.site-compliance-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--ui-muted) !important;
    text-decoration: none;
    white-space: nowrap;
}

.site-compliance-link:hover,
.site-compliance-link:focus-visible {
    color: var(--ui-text) !important;
}

.site-compliance-link img {
    width: 14px;
    height: 14px;
    flex: 0 0 14px;
}

.site-compliance-footer--fixed {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1000;
}

body.has-fixed-compliance-footer {
    --site-footer-height: calc(38px + env(safe-area-inset-bottom));
    padding-bottom: var(--site-footer-height) !important;
}

body.has-static-compliance-footer {
    padding-bottom: 0 !important;
}

body.chat-page .chat-layout {
    height: calc(100dvh - 56px - var(--site-footer-height));
}

body.tts-page .tts-shell {
    height: calc(100dvh - 12px - var(--site-footer-height));
}

button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid #5d8fbd;
    outline-offset: 2px;
}

* {
    scrollbar-width: thin;
    scrollbar-color: #aab5bf transparent;
}

*::-webkit-scrollbar {
    width: 9px;
    height: 9px;
}

*::-webkit-scrollbar-thumb {
    border: 2px solid transparent;
    border-radius: 8px;
    background: #aab5bf;
    background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
    background: #8795a1;
    background-clip: padding-box;
}

@media (max-width: 768px) {
    .navbar {
        min-height: 52px;
    }

    .dropdown-item {
        min-height: 40px;
    }

    .tool-card:hover {
        transform: none;
    }

    .navbar > .container-fluid {
        padding-inline: 12px;
    }

    body.video-downloader-page > .content-wrapper {
        padding: 12px 12px 56px;
    }

    body.video-processor-page > .content-wrapper {
        max-width: none;
        padding: 0 0 50px;
    }

    body.video-processor-page .tool-container {
        border-width: 0;
        border-radius: 0;
        box-shadow: none;
    }

    body.translation-workspace > .content-wrapper {
        max-width: none;
        padding-right: 8px !important;
        padding-left: 8px !important;
    }

    body.translation-workspace .navbar > .container-fluid {
        max-width: none;
        padding-right: 8px;
        padding-left: 8px;
    }

    .profile-body .profile-container {
        width: 100%;
        margin: 0 0 52px;
    }

    .profile-font-settings {
        padding: 12px;
    }

    .profile-font-controls {
        grid-template-columns: 1fr;
    }

    .context-glossary-dialog {
        margin: 0.5rem;
    }

    .context-glossary-dialog .modal-content {
        max-height: calc(100vh - 1rem);
    }

    .context-term-form {
        grid-template-columns: minmax(0, 1fr) 16px minmax(0, 1fr) 36px;
    }

    .context-term-language-form {
        grid-template-columns: minmax(0, 1fr) 16px minmax(0, 1fr) 36px;
    }

    .context-term-add {
        grid-column: 4;
        grid-row: 1;
    }

    .context-glossary-item {
        grid-template-columns: minmax(0, 1fr) 16px minmax(0, 1fr) 28px;
    }

}

@media (prefers-reduced-transparency: reduce) {
    .navbar.bg-dark,
    .navbar-dark.bg-dark,
    footer {
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
        background-color: var(--ui-surface) !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
