/* Quiet, opaque surfaces. Loaded after the legacy glass layers so application
   layout, visibility and state handling can stay independent of the material. */
html.liquid-glass {
    --lg-heading: #20242c;
    --ui-nav-text: #151922;
    --ui-nav-selected-text: #10345f;
    --lg-text: #30363f;
    --lg-muted: #48515e;
    --lg-placeholder: var(--lg-muted);
    --lg-accent: #214f8b;
    --lg-success: #1b5735;
    --lg-warning: #704307;
    --lg-danger: #8f1e30;
    --lg-control-success: var(--lg-success);
    --lg-control-warning: var(--lg-warning);
    --lg-control-danger: var(--lg-danger);
    --lg-control-success-bg: #eaf4ee;
    --lg-control-warning-bg: #fff6dc;
    --lg-control-danger-bg: #fbefef;
    --ui-focus-border: #7184a0;
    --ui-focus-halo: rgba(72, 101, 141, .10);
    --ui-focus-width: 1px;
    --ui-focus-offset: -1px;
    --lg-canvas: #f1f6fc;
    --lg-wallpaper: none;
    --lg-surface: #ffffff;
    --lg-elevated: #ffffff;
    --lg-input: #fafbfd;
    --lg-soft: #f6f8fb;
    --lg-hover: #f1f3f5;
    --lg-border: #ececef;
    --lg-line: #e7e8eb;
    --lg-reflection: none;
    --lg-panel-surface: #ffffff;
    --lg-floating-surface: #ffffff;
    --lg-navigation-surface: #ffffff;
    --lg-optical-tint: #ffffff;
    --lg-highlight: none;
    --lg-shadow: 0 0 16px rgba(28, 31, 36, .035);
    --lg-floating-shadow: 0 0 24px rgba(28, 31, 36, .055);
    --lg-selected: #eaf0f6;
    --lg-blur: none;
    --lg-radius: 20px;
    --lg-control-reader: #ffffff;
    --lg-control-heading: #f6f8fb;
    --tool-surface: var(--lg-soft);
    --tool-dialog: var(--lg-elevated);
    --tool-edge: none;
    --primary: var(--lg-accent);
    --primary-hover: #183d70;
    --primary-light: #eaf0f6;
    --glass-blur: none;
}

html.liquid-glass[data-theme="dark"] {
    --lg-heading: #f3f4f6;
    --ui-nav-text: #f7f8fa;
    --ui-nav-selected-text: #e3eeff;
    --lg-text: #e1e5eb;
    --lg-muted: #c5ccd5;
    --lg-placeholder: var(--lg-muted);
    --lg-accent: #c5ddff;
    --lg-success: #c3efd4;
    --lg-warning: #ffe0a4;
    --lg-danger: #ffc2c9;
    --lg-control-success: var(--lg-success);
    --lg-control-warning: var(--lg-warning);
    --lg-control-danger: var(--lg-danger);
    --lg-control-success-bg: #2b4035;
    --lg-control-warning-bg: #443a26;
    --lg-control-danger-bg: #442e34;
    --ui-focus-border: #8da3c0;
    --ui-focus-halo: rgba(167, 189, 219, .12);
    --lg-canvas: #18191b;
    --lg-wallpaper: none;
    --lg-surface: #232427;
    --lg-elevated: #27282c;
    --lg-input: #1e1f22;
    --lg-soft: #292a2e;
    --lg-hover: #303237;
    --lg-border: #303136;
    --lg-line: #36373d;
    --lg-reflection: none;
    --lg-panel-surface: #232427;
    --lg-floating-surface: #27282c;
    --lg-navigation-surface: #232427;
    --lg-optical-tint: #232427;
    --lg-highlight: none;
    --lg-shadow: 0 0 16px rgba(0, 0, 0, .12);
    --lg-floating-shadow: 0 0 24px rgba(0, 0, 0, .2);
    --lg-selected: #303946;
    --lg-blur: none;
    --lg-control-reader: #232427;
    --lg-control-heading: #292a2e;
    --primary-hover: #deebff;
    --primary-light: #303946;
}

/* Tool dialogs have locally scoped material tokens in the older sheet. */
html.liquid-glass body.tgto-app :is(#utility-tools-section, .utility-modal,
    .tbp-overlay, .organize-recognize-modal, .organize-detail-modal,
    .organize-clear-modal, .organize-inline-confirm-modal),
html.liquid-glass[data-theme="dark"] body.tgto-app :is(#utility-tools-section,
    .utility-modal, .tbp-overlay, .organize-recognize-modal, .organize-detail-modal,
    .organize-clear-modal, .organize-inline-confirm-modal) {
    --tool-surface: var(--lg-soft);
    --tool-dialog: var(--lg-elevated);
    --tool-edge: none;
}

html.liquid-glass body,
html.liquid-glass body.mobile-document-scroll,
html.liquid-glass.is-standalone-ios body {
    background: var(--lg-canvas) !important;
}

/* Dark neutral ink restores hierarchy without fading supporting copy.
   Accent, warning, success and danger tokens stay independent. */
html.liquid-glass.clean-ui:root body :is(.brand-text, .page-title,
    .config-subgroup-title, .form-label, .group-title, .emby-dashboard-title,
    .emby-setup-title, .emby-panel-title, .emby-metric-value,
    .emby-proxy-title, .emby-proxy-card-title, .proxy-settings-title,
    .proxy-settings-block-title, .proxy-settings-guide-title,
    .proxy-settings-save-panel-title, .utility-tool-card-label,
    .utility-tools-header h2, .utility-modal-title, .utility-ai-card-head h3,
    .utility-cover-section-title, .transfer-history-title, .transfer-source-title,
    .organize-recognize-title, .organize-clear-title, .organize-detail-title-wrap h3,
    .tbp-dialog-title, .tbp-section-title, .tbp-card-title,
    .login-title, .ssh-title, .ssh-brand strong, .ssh-label,
    .vfp-app-page-title strong, .vfp-section-title,
    .md-ranking-control-head strong, .md-ranking-group-head h4,
    .md-ranking-results-head h3, .md-calendar-shell-head h3,
    .md-calendar-day-head h4, .md-library-filter-panel-head strong,
    .md-work-detail-copy h1, .md-actor-profile-copy h1,
    .md-work-detail-section-head h2, .md-detail-resource-head h4) {
    color: var(--lg-heading) !important;
}
html.liquid-glass.clean-ui:root body :is(.config-subgroup-title, .form-label) {
    font-weight: 550 !important;
}
html.liquid-glass.clean-ui:root body .nav-item:not(.active) {
    color: var(--ui-nav-text) !important;
    font-weight: 500 !important;
}
html.liquid-glass.clean-ui:root body .nav-item.active {
    color: var(--ui-nav-selected-text) !important;
    font-weight: 600 !important;
}
html.liquid-glass.clean-ui:root body :is(.nav-category-btn, .nav-category-title) {
    color: var(--ui-nav-text) !important;
}
html.liquid-glass.clean-ui:root body :is(input:not([type="checkbox"]):not([type="radio"]):not([type="color"]), textarea, select) {
    color: var(--lg-text) !important;
    -webkit-text-fill-color: currentColor;
}
html.liquid-glass.clean-ui:root body :is(.form-input, .search-input, .login-input,
    .emby-setup-input, .proxy-settings-input, .utility-input) {
    background: var(--lg-input) !important;
    border-color: var(--lg-line) !important;
}
html.liquid-glass.clean-ui:root body :is(input, textarea)::placeholder {
    color: var(--lg-placeholder) !important;
    -webkit-text-fill-color: var(--lg-placeholder);
    font-weight: 400;
    opacity: 1 !important;
}
html.liquid-glass:root body :is(input, textarea, select):disabled:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]) {
    color: var(--lg-text) !important;
    -webkit-text-fill-color: currentColor;
    opacity: 1 !important;
    border-style: dashed;
}
html.liquid-glass.clean-ui:root body :is(.form-item.is-disabled,
    .utility-cover-cron-field.is-disabled) {
    opacity: 1 !important;
}
html.liquid-glass.clean-ui:root body .form-item.is-disabled {
    border-style: dashed;
}
html.liquid-glass:root body :is(.organize-wash-drag-handle, .kv-separator,
    .ssh-profile-bar-title) {
    color: var(--lg-text) !important;
}
html.liquid-glass:root body #organize-history-section :is(.transfer-filter-label,
    .transfer-status-select, .transfer-result-input, #organize-status-filter option) {
    color: var(--lg-text) !important;
}
html.liquid-glass.clean-ui:root body.tgto-app :is(.md-spotlight-title,
    .md-calendar-spotlight h2, .md-spotlight-stat-body strong,
    .md-calendar-spotlight-stat strong) {
    color: var(--lg-heading) !important;
}
html.liquid-glass.clean-ui:root body.tgto-app :is(.md-spotlight-desc,
    .md-calendar-spotlight-copy > p, .md-spotlight-tag, .md-calendar-kicker,
    .md-spotlight-stat-label, .md-spotlight-stat-body small,
    .md-calendar-spotlight-stat span,
    .md-calendar-spotlight-stat small, .md-calendar-spotlight time,
    .md-calendar-detail-hint, .md-calendar-feature-meta span) {
    color: var(--lg-muted) !important;
}

/* Semantic copy uses theme-aware ink, including legacy badges and async states.
   Keep colored text opaque; neutral copy uses its own three-level palette. */
/* Short state labels and operation feedback carry more weight than help text.
   Timestamps, field descriptions and unselected choices keep their own hierarchy. */
html.liquid-glass.clean-ui:root :is(body, #env-sections) :is(
    .emby-proxy-status, .emby-proxy-status-error, .emby-proxy-result,
    .proxy-settings-status, .proxy-settings-inline-result, .transfer-status-badge,
    .transfer-history-updated:is(.is-error, .is-success),
    .utility-ai-status, .utility-cover-status, .tg-transfer-enable-status,
    .tg-scheduled-status, .tg-scheduled-card-state, .tg-scheduled-card-error,
    .switch-label, .cron-helper-status, .qr115-status, .hdhive-auth-status,
    .hdhive-proxy-helper-status, .login-feedback, .restart-status,
    .toast, .toast-text, .vfp-toast, .vfp-page-status, .vfp-inline-status,
    .vfp-unsaved-badge, .vf-inline-warning-badge,
    .vfp-card-match-meta, .md-card-emby-status, .md-work-detail-monitor-status,
    .md-re0-checkin-state, .organize-detail-inline-status,
    .tbp-notice, .tbp-badge-enabled, .field-scope-badge,
    .notify-bot-status, .directory-selector-error, .pttransfer-records-state,
    .emby-proxy-records-loading, .emby-proxy-records-empty,
    .emby-invite-message, .emby-invite-status, .emby-invite-cleanup-error,
    .emby-deep-delete-guide-status, .emby-error, .emby-setup-badge, .emby-live-badge,
    .hdhive-user-panel-error, .hdhive-user-error-text, .hdhive-proxy-runtime-error,
    .vf-inline-status, .pikpak-captcha-modal-status, #ssh-status,
    .organize-retag-search-notice, .organize-recognize-hero-status,
    .utility-cover-library-badge, .utility-share-clean-detail-badge,
    .md-basic-config-unsaved-badge, .md-basic-config-panel-dirty,
    .md-library-choice-state, .md-library-cache-notice,
    .md-guanying-config-error, .md-work-detail-error,
    .md-state-inner, .md-state-inner > strong, .md-detail-resource-loading small,
    .md-badge:is(.is-accent, .is-warning, .is-success, .is-danger),
    [data-md-emby-config-status], [data-md-guanying-config-status], .log-error
) {
    font-weight: 600 !important;
}
html.liquid-glass.clean-ui:root :is(body, #env-sections) :is(
    .emby-proxy-status.disabled, .emby-proxy-result.info, .proxy-settings-status.info,
    .hdhive-auth-status-muted, .hdhive-proxy-helper-status.disabled,
    .tg-transfer-enable-status:not(.is-on):not(.is-error),
    .qr115-status:not(.success):not(.error), .restart-status,
    .switch-label:not(.is-danger), .switch-label.is-danger:not(.on),
    .notify-bot-status:not(.success):not(.error),
    .pttransfer-records-state:not(.is-error),
    .emby-proxy-records-loading, .emby-proxy-records-empty:not(.is-error),
    .emby-invite-message.info, .emby-invite-status:is(.deleted, .revoked),
    .emby-deep-delete-guide-status, .pikpak-captcha-modal-status, #ssh-status,
    .md-library-choice-state, .md-library-cache-notice,
    .md-state-inner, .md-state-inner > strong,
    .tg-scheduled-status.is-info, .tg-scheduled-card-state.idle,
    .organize-retag-search-notice, .toast-info, .toast-loading,
    .toast-info .toast-text, .toast-loading .toast-text, .vfp-toast.is-info
) {
    color: var(--lg-heading) !important;
}
/* Inline editor feedback sets semantic ink in JavaScript; keep that override. */
html.liquid-glass.clean-ui:root body .vf-inline-status {
    color: var(--lg-heading);
}
html.liquid-glass.clean-ui:root body :is(.emby-proxy-records-loading,
    .emby-proxy-records-empty) {
    opacity: 1 !important;
}
/* Long instructions remain regular; only their lead-in carries emphasis. */
html.liquid-glass.clean-ui:root body .md-state-inner > p {
    color: var(--lg-muted) !important;
    font-weight: 400 !important;
}
html.liquid-glass.clean-ui:root body :is(.tbp-trust-notice, .md-basic-callout,
    .md-monitor-dialog-notice, .config-subgroup-desc-warning, .qr115-warning,
    .utility-cover-plugin-alert) :is(strong, b),
html.liquid-glass.clean-ui:root body .config-subgroup-desc-warning::before {
    font-weight: 600 !important;
}
html.liquid-glass.clean-ui:root body :is(
    .config-subgroup-desc-warning:not(.is-notice):not(.is-caution),
    .qr115-warning-danger, .utility-cover-plugin-alert-danger
) {
    font-weight: 500 !important;
}
html.liquid-glass.clean-ui:root :is(body, #env-sections) :is(
    .field-scope-badge, .tg-transfer-card-title, .monitor-link-card-title,
    .tg-scheduled-card-state.running, .tg-scheduled-card-state.retrying,
    .tg-scheduled-card-state.queued, .emby-invite-status.unused
) {
    color: var(--lg-accent) !important;
}
html.liquid-glass.clean-ui:root :is(body, #env-sections) :is(
    .login-feedback, .vf-inline-warning-badge, .tg-transfer-enable-status.is-error,
    .emby-proxy-status-error, .emby-proxy-result.error,
    .tg-scheduled-status.is-error, .tg-scheduled-card-state.failed,
    .tg-scheduled-card-state.invalid_config, .tg-scheduled-card-error,
    .transfer-history-updated.is-error, .utility-ai-status.error,
    .utility-cover-status.error, .hdhive-auth-status-error,
    #share-strm-invalid-cleaner-stat-invalid, #share-strm-invalid-cleaner-stat-deleted,
    .cron-helper.is-invalid .cron-helper-status,
    .notify-bot-status.error, .pttransfer-records-state.is-error,
    .emby-proxy-records-empty.is-error, .emby-invite-message.error,
    .emby-invite-cleanup-error, .directory-selector-error, .emby-error,
    .hdhive-user-panel-error, .hdhive-user-error-text, .hdhive-proxy-runtime-error,
    .md-guanying-config-error, .md-work-detail-error, .log-error,
    .toast-error, .toast-error .toast-text, .vfp-toast.is-error, .emby-live-badge
) {
    color: var(--lg-control-danger) !important;
}
html.liquid-glass.clean-ui:root :is(body, #env-sections) :is(
    .hdhive-auth-status-warn, .hdhive-proxy-helper-status.warning,
    .hdhive-proxy-helper-status.pending, .organize-overwrite-rule-warning,
    .emby-deep-delete-guide-warning, .tg-scheduled-status.is-warning,
    .vfp-save-note, .vfp-save-note strong,
    .vfp-tool-section, .emby-invite-status.cleanup_pending,
    .md-basic-config-unsaved-badge, .md-basic-config-panel-dirty,
    .toast-warning, .toast-warning .toast-text
) {
    color: var(--lg-control-warning) !important;
}
html.liquid-glass.clean-ui:root body.tgto-app #env-sections .config-subgroup-desc-warning.is-caution::before {
    color: var(--lg-control-warning) !important;
}
html.liquid-glass.clean-ui:root :is(body, #env-sections) :is(
    .tg-transfer-enable-status.is-on, .tg-scheduled-status.is-success,
    .tg-scheduled-card-state.success, .transfer-history-updated.is-success,
    .utility-ai-status.success, .utility-cover-status.success, .emby-proxy-result.success,
    .hdhive-auth-status-ok,
    .hdhive-proxy-helper-status.ready, .vfp-assist-live,
    #share-strm-invalid-cleaner-stat-valid,
    .cron-helper.is-valid .cron-helper-status,
    .notify-bot-status.success, .emby-invite-message.success,
    .emby-invite-status.claimed, .toast-success, .toast-success .toast-text,
    .vfp-toast.is-success
) {
    color: var(--lg-control-success) !important;
}
html.liquid-glass.clean-ui:root :is(body, #env-sections) :is(
    .utility-ai-status.info, .utility-cover-status.info
) {
    color: var(--lg-heading) !important;
}
html.liquid-glass.clean-ui:root body .ssh-profile-chip.empty {
    opacity: 1 !important;
}
html.liquid-glass.clean-ui:root body :is(.field-scope-badge,
    .tg-transfer-card-title, .monitor-link-card-title) {
    background: var(--lg-selected) !important;
}
html.liquid-glass.clean-ui:root body :is(.vf-inline-warning-badge,
    .tg-scheduled-status.is-error) {
    background: var(--lg-control-danger-bg) !important;
}
html.liquid-glass.clean-ui:root body :is(.tg-scheduled-status.is-warning,
    .vfp-tool-section) {
    background: var(--lg-control-warning-bg) !important;
}
html.liquid-glass.clean-ui:root body :is(.emby-invite-message.error, .emby-live-badge,
    .hdhive-user-panel-error) {
    background: var(--lg-control-danger-bg) !important;
}
html.liquid-glass.clean-ui:root body :is(.emby-invite-message.success,
    .emby-invite-status.claimed) {
    background: var(--lg-control-success-bg) !important;
}
html.liquid-glass.clean-ui:root body .emby-invite-status.cleanup_pending {
    background: var(--lg-control-warning-bg) !important;
}
html.liquid-glass.clean-ui:root body .emby-invite-status.unused {
    background: var(--lg-selected) !important;
}
html.liquid-glass.clean-ui:root body :is(.emby-invite-message.info,
    .emby-invite-status.deleted, .emby-invite-status.revoked) {
    background: var(--lg-soft) !important;
}
html.liquid-glass.clean-ui:root body :is(.tg-scheduled-status.is-success,
    .vfp-assist-live) {
    background: var(--lg-control-success-bg) !important;
}

/* The shell is white in the light theme, with only a fine neutral boundary. */
html.liquid-glass body :is(.sidebar, .top-bar, .mobile-dock-card),
html.liquid-glass body.mobile-document-scroll :is(.sidebar.open, .top-bar, .mobile-dock-card),
html.liquid-glass body .top-bar.lg-optical-host,
html.liquid-glass body.mobile-document-scroll .top-bar.lg-optical-host {
    background: var(--lg-navigation-surface) !important;
    border-color: var(--lg-border) !important;
    box-shadow: var(--lg-shadow) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}
html.liquid-glass body :is(.top-bar, .mobile-dock-card)::after,
html.liquid-glass body .lg-optical-host > span.lg-optical-backdrop {
    content: none !important;
    display: none !important;
}
html.liquid-glass body .sidebar .nav-item.active {
    border-color: transparent !important;
    box-shadow: none !important;
    border-radius: 10px !important;
}
html.liquid-glass.clean-ui body .sidebar .nav-category-title {
    font-size: 13px !important;
    font-weight: 400 !important;
    line-height: 18px;
    letter-spacing: 0 !important;
}

/* These are content surfaces, not generic divs or application section roots. */
html.liquid-glass body :is(
    .config-group:not(.config-group-structured), .config-group-structured .config-subgroup,
    .emby-metric-card, .emby-panel, .emby-setup-panel, .emby-proxy-card,
    .emby-proxy-head, .emby-proxy-empty, .proxy-settings-card,
    .proxy-settings-block, .proxy-settings-head, .proxy-settings-guide, .proxy-settings-save-panel,
    .utility-card, .utility-tool-card, .tg-transfer-card, .monitor-link-card, .organize-history-toolbar,
    .transfer-history-toolbar, .md-filter-panel, .md-ranking-panel,
    .md-library-toolbar, .md-library-filter-panel, .md-calendar-toolbar,
    .md-ranking-control-panel, .md-ranking-results-shell, .md-calendar-shell,
    .md-spotlight-compact, .md-calendar-spotlight, .md-task-card, .md-basic-config-panel,
    .md-work-detail-hero, .md-work-detail-info-card, .md-work-detail-person-card,
    .md-work-detail-filmography, .md-tmdb-section, .md-work-detail-resource-panel,
    .md-work-detail-actor-hero, .md-actor-explore-panel, .md-actor-profile-hero,
    .md-actor-profile-aside, .md-actor-filmography-panel, .md-state,
    .md-work-detail-loading, .md-work-detail-error, .app-load-state,
    .vfp-editor-toolbar, .vfp-assist-panel, .vfp-rule-board,
    .ssh-config, .ssh-profile-bar
) {
    border-color: var(--lg-border) !important;
    border-radius: 20px !important;
    background: var(--lg-panel-surface) !important;
    box-shadow: var(--lg-shadow) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}
html.liquid-glass body #emby-setup-panel { border-radius: 20px !important; }
html.liquid-glass body .global-alert-banner {
    background: var(--lg-surface);
    border-color: var(--lg-border);
    border-radius: 14px;
    box-shadow: none;
}
html.liquid-glass body :is(.md-ranking-results-shell, .md-calendar-shell) .md-state {
    background: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
}

/* Inner groups are deliberately a shade quieter than the outer white cards. */
html.liquid-glass body :is(.config-subgroup, .utility-ai-card, .vf-inline-editor,
    .proxy-settings-guide-card, .proxy-settings-steps, .qr115-panel,
    .md-spotlight-stat-card, .md-calendar-spotlight-stat, .md-calendar-date-rail-wrap,
    .md-resource-filter-bar, .md-monitor-dialog-intro, .md-resource-card,
    .emby-live-card, .emby-user-card, .emby-invite-access-guide) {
    border-color: var(--lg-line) !important;
    border-radius: 12px !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}
/* A section owns its settings: the outer white panel carries the summary and
   a quiet inset area groups the smaller setting cards beneath it. */
html.liquid-glass.clean-ui body.tgto-app #env-sections .config-group-structured .config-subgroup {
    padding: 18px !important;
    border: 1px solid var(--lg-border) !important;
    border-radius: 18px !important;
    background: var(--lg-surface) !important;
    box-shadow: var(--lg-shadow) !important;
    overflow: visible;
}
html.liquid-glass.clean-ui body.tgto-app #env-sections .config-group-structured .config-subgroup-head {
    margin: 0 !important;
    padding: 0 !important;
    gap: 12px;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}
html.liquid-glass.clean-ui body.tgto-app #env-sections .config-group-structured .config-subgroup-title {
    font-size: 15px !important;
}
html.liquid-glass.clean-ui body.tgto-app #env-sections .config-group-structured .config-subgroup-body {
    gap: 10px;
    margin-top: 14px;
    padding: 12px;
    min-width: 0;
    border: 1px solid var(--lg-line);
    border-radius: 14px;
    background: var(--lg-input);
}
html.liquid-glass.clean-ui body.tgto-app #env-sections .config-group-structured .form-item {
    padding: 16px 18px !important;
    margin-bottom: 0;
    min-width: 0;
    border: 1px solid var(--lg-line) !important;
    border-radius: 14px !important;
    background: var(--lg-surface) !important;
    box-shadow: none !important;
}
html.liquid-glass.clean-ui body.tgto-app #env-sections .config-group-structured .form-header {
    flex-wrap: wrap;
    gap: 6px 10px;
    margin-bottom: 6px;
}
html.liquid-glass.clean-ui body.tgto-app #env-sections .form-label {
    min-width: 0;
    font-weight: 550 !important;
    overflow-wrap: anywhere;
}
html.liquid-glass.clean-ui body.tgto-app #env-sections .config-group-structured .form-desc {
    margin-bottom: 10px;
}
html.liquid-glass.clean-ui body.tgto-app #env-sections .config-group-structured .form-item:is(.config-search-target, .config-search-highlight) {
    border-color: var(--lg-accent) !important;
    box-shadow: 0 0 0 3px var(--ui-focus-halo) !important;
}

/* Editable rows keep their remove action in the row. Directory rules use the
   available width instead of squeezing two inputs and a picker into half a card. */
html.liquid-glass.clean-ui body.tgto-app #env-sections :is(.key-value-card-list, .value-list-card-list):where(:not(.release-group-priority-list):not(.pansou-grid)) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
html.liquid-glass.clean-ui body.tgto-app #env-sections :is(.key-value-directory-list, .value-list-card-list.single-column, .key-value-card-list.single-column) {
    grid-template-columns: minmax(0, 1fr) !important;
}
html.liquid-glass.clean-ui body.tgto-app #env-sections :is(.key-value-card, .value-list-card) {
    border-color: var(--lg-line) !important;
    border-radius: 10px !important;
    background: var(--lg-soft) !important;
    box-shadow: none !important;
    transform: none !important;
}
html.liquid-glass.clean-ui body.tgto-app #env-sections .key-value-directory-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) 36px;
    gap: 10px;
    padding: 10px;
}
html.liquid-glass.clean-ui body.tgto-app #env-sections .key-value-directory-card > .kv-separator {
    display: none;
}
html.liquid-glass.clean-ui body.tgto-app #env-sections .key-value-directory-card > .directory-selector-mini-input-wrap {
    width: auto !important;
    min-width: 0;
}
html.liquid-glass.clean-ui body.tgto-app #env-sections .key-value-directory-card :is(.kv-key-input, .kv-value-input) {
    min-width: 0;
    width: 100%;
}
html.liquid-glass.clean-ui body.tgto-app #env-sections .key-value-wrapper .kv-add-btn {
    align-self: flex-start;
    width: auto !important;
    margin-top: 0 !important;
}
html.liquid-glass.clean-ui body.tgto-app #env-sections .value-list-card-list.ext-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(148px, 100%), 1fr)) !important;
    gap: 8px;
}
html.liquid-glass.clean-ui body.tgto-app #env-sections .ext-grid .value-list-card {
    padding: 7px;
    gap: 7px;
}

/* The raw whitelist remains selectable and wraps long expressions naturally. */
html.liquid-glass.clean-ui body.tgto-app #env-sections .form-item > .vf-inline-editor {
    padding: 0;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    gap: 8px;
    min-width: 0;
}
html.liquid-glass.clean-ui body.tgto-app #env-sections .vf-inline-preview {
    box-sizing: border-box;
    width: 100%;
    min-height: 88px;
    padding: 11px 12px !important;
    font-family: var(--lg-font-ui);
    font-size: 14px;
    line-height: 1.7;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
@media (max-width: 768px) {
    html.liquid-glass.clean-ui body.tgto-app #env-sections .config-group-structured .config-subgroup {
        padding: 14px !important;
    }
    html.liquid-glass.clean-ui body.tgto-app #env-sections .config-group-structured .config-subgroup-body {
        padding: 8px;
    }
    html.liquid-glass.clean-ui body.tgto-app #env-sections .config-group-structured .form-item {
        padding: 12px !important;
    }
    html.liquid-glass.clean-ui body.tgto-app #env-sections :is(.key-value-card-list, .value-list-card-list) {
        grid-template-columns: minmax(0, 1fr);
    }
    html.liquid-glass.clean-ui body.tgto-app #env-sections .key-value-directory-card {
        grid-template-columns: minmax(0, 1fr) 44px;
        gap: 8px;
    }
    html.liquid-glass.clean-ui body.tgto-app #env-sections .key-value-directory-card > .kv-key-input {
        grid-column: 1;
        grid-row: 1;
    }
    html.liquid-glass.clean-ui body.tgto-app #env-sections .key-value-directory-card > .kv-delete-btn {
        grid-column: 2;
        grid-row: 1;
    }
    html.liquid-glass.clean-ui body.tgto-app #env-sections .key-value-directory-card > .directory-selector-mini-input-wrap {
        grid-column: 1 / -1;
        grid-row: 2;
    }
    html.liquid-glass.clean-ui body.tgto-app #env-sections .vf-inline-preview {
        font-size: 16px;
    }
}
@media (max-width: 1100px) {
    html.liquid-glass.clean-ui body.tgto-app #env-sections .monitor-link-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}
@media (max-width: 400px) {
    html.liquid-glass.clean-ui body.tgto-app #env-sections .directory-selector-mini-input-wrap {
        flex-wrap: wrap;
    }
    html.liquid-glass.clean-ui body.tgto-app #env-sections .directory-selector-mini-input-wrap > .directory-selector-mini-btn {
        width: 100%;
    }
}
html.liquid-glass body :is(.proxy-settings-guide-card, .md-spotlight-stat-card,
    .md-calendar-spotlight-stat, .emby-invite-access-guide) {
    background: var(--lg-soft) !important;
}
html.liquid-glass body :is(.organize-batch-toolbar, .md-ranking-vlib-toggle,
    .md-ranking-vlib-section, .md-basic-callout, .config-subgroup-desc.is-callout) {
    background: var(--lg-soft) !important;
    border-color: var(--lg-line) !important;
    border-radius: 12px;
    box-shadow: none !important;
}
html.liquid-glass body .config-subgroup-desc.is-callout::before {
    color: var(--lg-muted) !important;
}
html.liquid-glass body .organize-batch-toolbar.is-selection-mode {
    border-color: var(--lg-accent) !important;
}
html.liquid-glass body .md-basic-config-panel.is-dirty {
    border-color: color-mix(in srgb, var(--lg-control-warning) 38%, var(--lg-line)) !important;
}
html.liquid-glass body.tgto-app .utility-modal :is(.utility-ai-card,
    .utility-modal-card, .utility-cover-section, .utility-cover-action-card,
    .utility-share-clean-stat-card, .utility-share-clean-detail-summary,
    .utility-share-clean-detail-item, .utility-tmdb-search-result-card,
    .utility-tmdb-regex-card, .utility-cover-library-item,
    .utility-share-clean-log-item, .utility-share-clean-history-item,
    .utility-cover-plugin-card, .utility-share-clean-config-card,
    .utility-share-clean-progress-card, .utility-share-clean-history-card,
    .utility-share-clean-detail-card) {
    background: var(--lg-surface) !important;
    border-color: var(--lg-line) !important;
    border-radius: 12px !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}
/* Tool cards keep the outer panel surface; their fields and inner rows inherit
   the same quiet inset colors as the rest of the application. */
html.liquid-glass.clean-ui:root body.tgto-app .utility-modal :is(.form-input,
    .utility-custom-release-groups-input, .utility-cover-code-editor) {
    background: var(--lg-input) !important;
    border-color: var(--lg-line) !important;
}
html.liquid-glass.clean-ui:root body.tgto-app .utility-modal :is(.utility-cover-helper,
    .utility-ai-helper) code {
    color: var(--lg-text) !important;
    background: var(--lg-input) !important;
}
html.liquid-glass body :is(.search-input, .md-pagination-page,
    .md-work-detail-monitor-status),
html.liquid-glass body.tgto-app :is(#env-sections, .utility-modal, .tbp-dialog)
    :is(input, select, textarea),
html.liquid-glass body.tgto-app #utility-bot-commands-modal
    :is(.transfer-history-header, .transfer-history-container),
html.liquid-glass body.tgto-app #organize-history-section #organize-batch-toolbar {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}
html.liquid-glass body.tgto-app #env-sections :is(.transfer-table-wrap,
    .log-viewer-container, .proxy-settings-results) {
    background: var(--lg-control-reader);
    border-color: var(--lg-line);
    border-radius: 12px;
    box-shadow: none;
}

/* Save/restart keeps the familiar full-screen wait with a readable countdown. */
html.liquid-glass.clean-ui:root body .restart-overlay {
    --lg-heading: #f3f4f6;
    --lg-text: #e1e5eb;
    --lg-muted: #c5ccd5;
    --ui-button-bg: #283445;
    --ui-button-hover: #344257;
    --ui-button-pressed: #3c4c63;
    --ui-button-border: #61738c;
    --ui-button-text: #f3f4f6;
    --ui-focus-border: #a8c9fa;
    --ui-focus-halo: rgba(168, 201, 250, .18);
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: grid;
    place-items: center;
    overflow-y: auto;
    padding: 24px;
    box-sizing: border-box;
    background: rgba(15, 23, 42, .94);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    color: var(--lg-text);
    text-align: center;
}
html.liquid-glass.clean-ui:root body .restart-overlay .restart-countdown-dialog {
    width: min(100%, 480px);
    margin: auto;
    padding: 24px 0;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}
html.liquid-glass.clean-ui:root body .restart-overlay .restart-spinner {
    display: inline-block;
    margin-bottom: 20px;
    font-size: 48px;
    line-height: 1;
    animation: restart-wait-spin 2s linear infinite;
}
html.liquid-glass.clean-ui:root body .restart-overlay #restart-title {
    margin: 0 0 12px;
    color: var(--lg-heading);
    font-size: 20px;
    font-weight: 600;
    line-height: 1.5;
    overflow-wrap: anywhere;
}
html.liquid-glass.clean-ui:root body .restart-overlay .restart-status {
    margin: 0;
    font-size: 14px;
    line-height: 1.7;
}
html.liquid-glass.clean-ui:root body .restart-overlay .restart-countdown {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 8px;
    margin: 22px 0 4px;
    color: var(--lg-heading);
    font-variant-numeric: tabular-nums;
}
html.liquid-glass.clean-ui:root body .restart-overlay .restart-countdown-value {
    font-size: 52px;
    font-weight: 650;
    line-height: 1.15;
}
html.liquid-glass.clean-ui:root body .restart-overlay .restart-countdown-unit {
    font-size: 14px;
    font-weight: 500;
}
html.liquid-glass.clean-ui:root body .restart-overlay :is(.restart-countdown-caption, .restart-note) {
    margin: 0;
    color: var(--lg-muted);
    font-size: 13px;
    font-weight: 400;
    line-height: 1.8;
    overflow-wrap: anywhere;
}
html.liquid-glass.clean-ui:root body .restart-overlay .restart-note { margin-top: 16px; }
html.liquid-glass.clean-ui:root body .restart-overlay .restart-cancel-btn { margin-top: 24px; }
@keyframes restart-wait-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
    html.liquid-glass.clean-ui:root body .restart-overlay .restart-spinner { animation: none; }
}

/* Menus and dialogs have an opaque reading surface; overlays stay neutral. */
html.liquid-glass body :is(.search-results, .search-results-dropdown,
    .config-search-results, .custom-confirm-modal, .modal-content, .restart-dialog,
    .utility-modal, .directory-selector-panel, .notify-bot-panel,
    .organize-recognize-panel, .organize-detail-panel, .organize-clear-panel,
    .organize-inline-confirm-dialog, .md-modal, .md-dialog, .tbp-dialog,
    .vfp-dialog, .vfp-tools-drawer, .vfp-preview-drawer, .vfp-search-drawer) {
    background: var(--lg-elevated) !important;
    border-color: var(--lg-border) !important;
    border-radius: 20px !important;
    box-shadow: var(--lg-floating-shadow) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}
html.liquid-glass body :is(.overlay, .md-modal-backdrop, .utility-modal-overlay,
    .directory-selector-backdrop, .notify-bot-backdrop, .vf-modal-backdrop,
    .organize-inline-confirm-backdrop, .organize-clear-mask, .organize-detail-mask,
    .organize-recognize-mask, .pttransfer-records-mask, .pikpak-captcha-modal-overlay,
    .tbp-overlay, .vfp-modal-backdrop) {
    background: rgba(24, 25, 28, .28) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}
html.liquid-glass body :is(.utility-modal-header, .tbp-dialog-header,
    .organize-clear-header, .organize-recognize-header) {
    background: transparent !important;
    border-color: var(--lg-line) !important;
}
html.liquid-glass body :is(.organize-recognize-result-shell,
    .organize-recognize-card, .organize-clear-date-card,
    .organize-clear-calendar-shell, .organize-clear-field-row) {
    background: var(--lg-soft) !important;
    border-color: var(--lg-line) !important;
    box-shadow: none !important;
}
html.liquid-glass body :is(.config-subgroup-icon, .proxy-settings-block-icon,
    .organize-clear-icon, .ssh-brand-mark),
html.liquid-glass body .emby-setup-features li > span,
html.liquid-glass body:is(.vfp-app-body, .vfp-inline-editor-open) .vfp-empty-icon {
    background: var(--lg-soft) !important;
    border-color: var(--lg-line) !important;
    box-shadow: none !important;
}

/* Discovery headers retain their artwork, with a dark reading layer for text. */
html.liquid-glass.clean-ui:root body :is(.md-spotlight-compact, .md-calendar-spotlight) {
    --lg-heading: #fff;
    --lg-text: #f3f6fc;
    --lg-muted: #e0e8f4;
    --lg-soft: rgba(15, 23, 42, .88);
    --lg-input: rgba(15, 23, 42, .88);
    --lg-surface: rgba(15, 23, 42, .88);
    --lg-border: rgba(224, 232, 244, .22);
    --lg-line: rgba(224, 232, 244, .18);
    background: #172438 !important;
}
html.liquid-glass.clean-ui:root body :is(.md-spotlight-backdrop, .md-calendar-spotlight-backdrop) {
    display: block;
    opacity: .85;
    filter: none;
    transform: none;
    background-image: none;
    background-position: center 40%;
    background-size: cover;
}
html.liquid-glass.clean-ui:root body :is(.md-spotlight-shade, .md-calendar-spotlight-shade) {
    display: block;
    background: linear-gradient(90deg, rgba(12, 20, 35, .96) 0%, rgba(12, 20, 35, .90) 45%, rgba(12, 20, 35, .32) 76%, rgba(12, 20, 35, .58) 100%);
}
/* Remove only the decorative duplicates outside those media headers. */
html.liquid-glass body :is(.md-work-detail-backdrop,
    .md-work-detail-hero-shade, .md-actor-profile-hero-art, .lg-media-art-orbit) {
    display: none !important;
}
html.liquid-glass body .utility-tool-card::before { content: none !important; }
html.liquid-glass body .utility-tool-card:nth-child(n) .utility-tool-card-icon,
html.liquid-glass[data-theme="dark"] body .utility-tool-card:nth-child(n) .utility-tool-card-icon {
    background: var(--lg-soft) !important;
    color: var(--lg-accent) !important;
    border-color: var(--lg-line) !important;
    box-shadow: none !important;
}
html.liquid-glass body :is(.lg-empty-tile, .lg-media-art-tile, .lg-media-art-spark) {
    background: var(--lg-soft);
    border-color: var(--lg-line);
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

/* Tool shortcuts use compact rows without truncating their descriptions. */
html.liquid-glass.clean-ui body.tgto-app #utility-tools-section .utility-tools-page {
    gap: 16px;
}
html.liquid-glass.clean-ui body.tgto-app #utility-tools-section .utility-tools-header {
    margin-bottom: 0;
}
html.liquid-glass.clean-ui body.tgto-app #utility-tools-section .utility-tools-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 12px !important;
}
html.liquid-glass.clean-ui body.tgto-app #utility-tools-section .utility-tool-card {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) 12px;
    grid-template-rows: auto auto;
    column-gap: 12px;
    row-gap: 5px;
    align-items: start;
    align-content: center;
    min-height: 112px;
    padding: 16px !important;
    border-radius: 14px !important;
    text-decoration: none;
    transition: border-color .15s ease, box-shadow .15s ease !important;
}
html.liquid-glass.clean-ui body.tgto-app #utility-tools-section .utility-tool-card-icon {
    grid-column: 1;
    grid-row: 1 / 3;
    width: 34px !important;
    height: 34px !important;
    border-radius: 10px !important;
}
html.liquid-glass.clean-ui body.tgto-app #utility-tools-section .utility-tool-card-icon svg {
    width: 18px;
    height: 18px;
}
html.liquid-glass.clean-ui body.tgto-app #utility-tools-section .utility-tool-card-label {
    grid-column: 2;
    grid-row: 1;
    align-self: center;
    margin: 0;
    font-size: 14px !important;
    line-height: 22px;
}
html.liquid-glass.clean-ui body.tgto-app #utility-tools-section .utility-tool-card-desc {
    grid-column: 2;
    grid-row: 2;
    margin: 0;
    font-size: 13px !important;
    line-height: 1.65 !important;
    overflow-wrap: anywhere;
}
html.liquid-glass.clean-ui body.tgto-app #utility-tools-section .utility-tool-card-meta {
    grid-column: 3;
    grid-row: 1 / 3;
    align-self: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    font-size: 0 !important;
}
html.liquid-glass.clean-ui body.tgto-app #utility-tools-section .utility-tool-card-meta::after {
    content: '\203a';
    margin: 0;
    font-size: 20px;
    line-height: 1;
    color: var(--lg-muted);
    transform: none !important;
    transition: none;
}
html.liquid-glass.clean-ui body.tgto-app #utility-tools-section .utility-tool-card:hover {
    transform: none !important;
    border-color: color-mix(in srgb, var(--lg-accent) 28%, var(--lg-line)) !important;
}
html.liquid-glass.clean-ui body.tgto-app #utility-tools-section .utility-tool-card:focus-visible {
    outline: var(--ui-focus-width) solid var(--ui-focus-border) !important;
    outline-offset: var(--ui-focus-offset) !important;
    box-shadow: 0 0 0 3px var(--ui-focus-halo) !important;
}
@media (min-width: 1600px) {
    html.liquid-glass.clean-ui body.tgto-app #utility-tools-section .utility-tools-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    }
}
@media (max-width: 1100px) {
    html.liquid-glass.clean-ui body.tgto-app #utility-tools-section .utility-tools-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}
@media (max-width: 600px) {
    html.liquid-glass.clean-ui body.tgto-app #utility-tools-section .utility-tools-grid {
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 10px !important;
    }
    html.liquid-glass.clean-ui body.tgto-app #utility-tools-section .utility-tool-card {
        min-height: 104px;
        padding: 14px !important;
        column-gap: 10px;
    }
}
html.liquid-glass body :is(.md-library-tile-kind, .md-library-tile-score,
    .md-calendar-card-kind, .md-calendar-card-score, .md-ranking-tile .md-score,
    .md-ranking-tile .md-rank, .md-actor-card-label, .md-actor-card-heat,
    .md-actor-work-kind, .md-actor-work-score) {
    background: rgba(24, 25, 28, .82);
    border-color: rgba(255, 255, 255, .16);
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

/* Standalone pages use the same white panels as the main application. */
html.liquid-glass body.lg-login-page .login-card,
html.liquid-glass body.lg-ssh-page .ssh-header {
    background: var(--lg-panel-surface) !important;
    border-color: var(--lg-border) !important;
    border-radius: 20px !important;
    box-shadow: var(--lg-shadow) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}
html.liquid-glass body.lg-login-page .login-logo {
    background: var(--lg-soft);
    border-color: var(--lg-line);
    box-shadow: none;
}
html.liquid-glass body.lg-ssh-page .ssh-terminal-panel {
    --lg-heading: #f3f4f6;
    --lg-text: #e1e5eb;
    --lg-muted: #c5ccd5;
    --lg-placeholder: var(--lg-muted);
    color: var(--lg-text);
    background: #1d1f23;
    border-color: #33363d;
    border-radius: 20px;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
html.liquid-glass:root body.lg-ssh-page .ssh-field .form-input {
    color: var(--lg-text) !important;
}
html.liquid-glass body.lg-ssh-page :is(.ssh-terminal-title, .ssh-command-form) {
    color: var(--lg-muted);
    background: #24262b;
    border-color: #33363d;
}
html.liquid-glass body.lg-ssh-page #cmd-input {
    background: transparent !important;
    color: var(--lg-text) !important;
}
html.liquid-glass:root body.lg-ssh-page #cmd-input::placeholder {
    color: var(--lg-placeholder) !important;
}
html.liquid-glass body #ssh-section .ssh-tip-box {
    background: var(--lg-soft);
    color: var(--lg-muted);
    border-color: var(--lg-line);
    box-shadow: none;
}
html.liquid-glass body #ssh-section .ssh-header-icon { filter: none; }
html.liquid-glass body:is(.vfp-app-body, .vfp-inline-editor-open) .vfp-rule-card {
    border-radius: 12px !important;
    box-shadow: none !important;
}

@media (min-width: 769px) {
    html.liquid-glass body .sidebar { border-radius: 18px; }
    html.liquid-glass body .top-bar { border-radius: 16px; }
}
@media (max-width: 768px) {
    html.liquid-glass body .sidebar { border-radius: 0 18px 18px 0; }
    html.liquid-glass body .top-bar { border-radius: 0 0 16px 16px; }
}

/* Keep keyboard focus close to the control instead of drawing a second frame.
   Dialog containers receive focus for navigation; their controls show the cue. */
html.liquid-glass.clean-ui:root :is(body, #env-sections) :is(button, a, input,
    select, textarea, summary, [tabindex], [role="button"]):not([role="dialog"]):focus-visible {
    outline: var(--ui-focus-width) solid var(--ui-focus-border) !important;
    outline-offset: var(--ui-focus-offset) !important;
    box-shadow: 0 0 0 3px var(--ui-focus-halo) !important;
}
html.liquid-glass.clean-ui:root body [role="dialog"]:focus-visible {
    outline: none !important;
}

@media (forced-colors: active) {
    html.liquid-glass,
    html.liquid-glass[data-theme="dark"] {
        --lg-heading: CanvasText;
        --lg-text: CanvasText;
        --lg-muted: CanvasText;
        --lg-placeholder: GrayText;
        --lg-accent: LinkText;
        --ui-focus-border: Highlight;
        --ui-focus-halo: transparent;
        --ui-focus-width: 2px;
        --ui-focus-offset: 2px;
        --lg-canvas: Canvas;
        --lg-surface: Canvas;
        --lg-elevated: Canvas;
        --lg-input: Canvas;
        --lg-soft: Canvas;
        --lg-border: CanvasText;
        --lg-line: CanvasText;
        --lg-panel-surface: Canvas;
        --lg-floating-surface: Canvas;
        --lg-navigation-surface: Canvas;
        --lg-selected: Canvas;
        --lg-shadow: none;
        --lg-floating-shadow: none;
    }
}
